#!/bin/bash
jar=/opt/module/gmall210323/gmall-realtime-1.0-SNAPSHOT.jar
flink=/opt/module/flink-yarn/bin/flink

apps=(
com.atguigu.gmall.realtime.app.dwd.DwdLog
com.atguigu.gmall.realtime.app.dwd.DwdDb
com.atguigu.gmall.realtime.app.dwm.DwmUv
com.atguigu.gmall.realtime.app.dwm.DwmUserJumpDetail_1
com.atguigu.gmall.realtime.app.dwm.DwmOrderWide_Cache_Async
com.atguigu.gmall.realtime.app.dwm.DwmPaymentWide
com.atguigu.gmall.realtime.app.dws.DwsVisitor
com.atguigu.gmall.realtime.app.dws.DwsProduct
com.atguigu.gmall.realtime.app.dws.DwsProvince
)

# 获取所有已经起来的appname
app_names=`$flink list -r 2>/dev/null | awk '/RUNNING/ {print \$(NF-1)}'`
for app in ${apps[*]} ; do
    app_name=`echo $app | awk -F. '{print \$NF}'`
    if [[ "${app_names[@]}" =~ $app_name ]]; then
    	echo "$app_name 已经启动无需重新启动"
    else
	    echo 开始启动$app_name
    	${flink} run -d -c ${app} ${jar}
    fi
done
